/*
   ______   ______    
  /\__  __\/\ \___\ 
  \/_/\ \_/\ \ \__/    __   __     __       
	 \ \ \  \ \ \__\  /\ \ /\ \  /'__`\
	 _\_\ \  \ \ \_/_ \ \ \\_\ \/\  __/
	/\____/   \ \_____\\ \_____/\ \____\
	\_/__/     \/_____/ \/____/  \/____/

	 This file is part of the JEVE core API.

	JEve is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	JEve is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.

	Copyright 2008 JEve Project (JEveProject@gmail.com)
 */
package be.fomp.jeve.core.api.connectors;

import be.fomp.jeve.core.api.FullAPI;
import be.fomp.jeve.core.api.url.FullUrl;
import be.fomp.jeve.core.config.CoreConfiguration;
import be.fomp.jeve.core.exceptions.JEveConnectionException;
import be.fomp.jeve.core.exceptions.JEveParseException;
import be.fomp.jeve.core.util.ParameterString;
import org.jdom.Document;

/**
 * <pre>
 *  ______   ______
 * /\__  __\/\ \___\
 * \/_/\ \_/\ \ \__/    __   __     __
 *    \ \ \  \ \ \__\  /\ \ /\ \  /'__`\
 *    _\_\ \  \ \ \_/_ \ \ \\_\ \/\  __/
 *   /\____/   \ \_____\\ \_____/\ \____\
 *   \_/__/     \/_____/ \/____/  \/____/
 * </pre>
 * This file is part of the JEVE core API.<br />
 * <br />
 * <p/>
 * This class contains the accessor methods for the EVE-Online API
 * which require a full API key.
 * <p/>
 * * Default visibility: This class should only be created using the factory
 *
 * @author Sven Meys
 */
class FullConnector extends LimitedConnector implements FullAPI {

	/**
	 * Constructor which takes a configuration setting. This configures the correct
	 * proxy settings to ensure the client can access the internet.
	 *
	 * @param config The configuration settings
	 */
	protected FullConnector(CoreConfiguration config) {
		super(config);
	}

	public final Document getAccountBallance(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.ACCOUNT_BALLANCE, parameters);
	}

	
	public final Document getAssetList(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.ASSET_LIST, parameters);
	}

	
	public final Document getCorpAccountBallance(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.CORP_ACCOUNT_BALLANCE, parameters);
	}

	
	public final Document getCorpAssetList(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.CORP_ASSET_LIST, parameters);
	}

	
	public final Document getCorpIndustryJobs(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.CORP_INDUSTRY_JOBS, parameters);
	}

	
	public final Document getCorpKillLog(int userID, String apiKey, int characterID, int beforeKillID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		if (beforeKillID > 0) {
			parameters.addParameter("beforeKillID", beforeKillID);
		}

		return getDocumentData(FullUrl.CORP_KILL_LOG, parameters);
	}

	
	public final Document getCorpMarketOrders(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.CORP_MARKET_ORDERS, parameters);
	}

	
	public final Document getCorpMemberTracking(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.CORP_MEMBER_TRACKING, parameters);
	}

	
	public final Document getCorpStarbaseDetail(int userID, String apiKey, int characterID, int itemID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID)
				.addParameter("itemID", itemID);

		return getDocumentData(FullUrl.CORP_STARBASE_DETAIL, parameters);
	}

	
	public final Document getCorpStarbaseList(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.CORP_STARBASE_LIST, parameters);
	}

	
	public final Document getCorpWalletJournal(int userID, String apiKey, int characterID, int accountKey, int beforeRefID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID)
				.addParameter("accountKey", accountKey);

		if (beforeRefID > 0) {
			parameters.addParameter("beforeRefID", beforeRefID);
		}

		return getDocumentData(FullUrl.CORP_WALLET_JOURNAL, parameters);
	}

	
	public final Document getCorpWalletTransactions(int userID, String apiKey, int characterID, int accountKey, int beforeTransID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID)
				.addParameter("accountKey", accountKey);
		if (beforeTransID > 0) {
			parameters.addParameter("beforeTransID", beforeTransID);
		}

		return getDocumentData(FullUrl.CORP_WALLET_TRANSACTIONS, parameters);
	}

	
	public final Document getIndustryJobs(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.INDUSTRY_JOBS, parameters);
	}

	
	public final Document getKillLog(int userID, String apiKey, int characterID, int beforeKillID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		if (beforeKillID > 0) {
			parameters.addParameter("beforeKillID", beforeKillID);
		}

		return getDocumentData(FullUrl.KILL_LOG, parameters);
	}

	
	public final Document getMarketOrders(int userID, String apiKey, int characterID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);

		return getDocumentData(FullUrl.MARKET_ORDERS, parameters);
	}

	
	public final Document getWalletJournal(int userID, String apiKey, int characterID, int beforeRefID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID)
						// Account key is always 1000 for characters
				.addParameter("accountKey", 1000);
		if (beforeRefID > 0) {
			parameters.addParameter("beforeRefID", beforeRefID);
		}

		return getDocumentData(FullUrl.WALLET_JOURNAL, parameters);
	}

	
	public final Document getWalletTransactions(int userID, String apiKey, int characterID, int beforeTransID) throws JEveConnectionException, JEveParseException {

		ParameterString parameters = new ParameterString();
		parameters.addParameter("userID", userID)
				.addParameter("apiKey", apiKey)
				.addParameter("characterID", characterID);
		if (beforeTransID > 0) {
			parameters.addParameter("beforeRefID", beforeTransID);
		}

		return getDocumentData(FullUrl.WALLET_TRANSACTIONS, parameters);
	}
}
